#include "scene.h"
#include <cmath>
#include <GL/gl.h>
#include <iostream>


Scene::Scene(){
    idObjects = 0;
}

Scene::~Scene(){
    unsigned int size = objects.size();
    for(unsigned int i = 0; i < size; i++){
        Object *obj = objects.back();
        objects.pop_back();
        delete obj;
    }
}

void Scene::addObject(Object *_o){
    objects.push_back(_o);
}

Object *Scene::getObject(unsigned int _i) const{
    return objects[_i];
}

unsigned int Scene::getObjectsSize() const{
    return objects.size();
}

void Scene::deleteObject(Object *_o){
    int size = objects.size();
    for (int i = size; i > 0; i--){
        if ( objects.at(i - 1) == _o ){
            objects.erase(objects.begin() + i - 1);
        }
    }
}

int Scene::nextObjectsID(){
    return idObjects++;
}

void Scene::setNextObjectsID(int _id){
    idObjects = _id + 1;
}

void Scene::draw(bool _showObjectFace, bool _showObjectEdge, bool _showObjectVertex, bool _showNormal){
    Object *obj;
    for(unsigned int i = 0; i < objects.size(); i++){
        obj = objects.at(i);
        obj->draw(_showObjectFace, _showObjectEdge, _showObjectVertex, _showNormal);
    }
}
